
$.ajax({
        url : "/AttendenceManager/selectUser",
        type : "post",
        success : function(data) {
            for (var i = 0; i < data.length; i++) {
                $('#proName').append(
                    "<option name='sb' value=" + data[i].userid + ">" + data[i].name + "</option>");
            }
        },
        error : function() {
            alert("请求超时，稍后再试！")
        }
    });

$("#proName").change(function(){
    $('#UserAttendTable').bootstrapTable('destroy');//先销毁表格，不然不会刷信
    userid = $("#proName option:selected").val();
    drawTable(userid);
});





function drawTable(userid) {
    $(function () {
        $('#UserAttendTable').bootstrapTable({
            url: '/AttendenceManager/selectAttend',
            method: 'get',
            queryParams:function(params) {
                return {
                    userid:userid
                };

            },
            showRefresh: true,  //显示刷新按钮
            toolbar: '#toolbar',
            striped: true,     //设置为true会有隔行变色效果
            //sidePagination:'server',//服务器端分页默认接受rows和total
            pagination: true,//客户端分页
            sidePagination: 'client',
            idFiled: 'studentSelectCourseId',
            pageNumber: 1,
            pageSize: 10,
            columns: [
                {
                    field: 'name',
                    title: '姓名'
                }
                , {
                    field: 'positionName',
                    title: '岗位'
                }, {
                    field: 'attend_in_time',
                    title: '签到时间',
                    formatter: function (attend_in_time) {
                        var tmpDate = new Date(attend_in_time);
                        var yy = tmpDate.getFullYear();

                        var m = tmpDate.getMonth() + 1;

                        var dd = tmpDate.getDate();

                        var hh = tmpDate.getHours();

                        var mm = tmpDate.getMinutes();

                        var ss = tmpDate.getSeconds();

                        return yy + '-' + m + '-' + dd + ' ' + hh + ':' + mm + ':' + ss;

                    }
                }, {
                    field: 'attend_out_time',
                    title: '签退时间',
                    formatter: function (attend_out_time) {
                        var tmpDate = new Date(attend_out_time);
                        var yy = tmpDate.getFullYear();

                        var m = tmpDate.getMonth() + 1;

                        var dd = tmpDate.getDate();

                        var hh = tmpDate.getHours();

                        var mm = tmpDate.getMinutes();

                        var ss = tmpDate.getSeconds();

                        return yy + '-' + m + '-' + dd + ' ' + hh + ':' + mm + ':' + ss;

                    }

                }
            ]
        });
    });
}
